```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Java方法重载与重写详解 | 技术小馆</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            line-height: 1.6;
            color: #333;
            background-color: #f9f9f9;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #6e48aa 0%, #9d50bb 100%);
        }
        .code-block {
            background-color: #2d2d2d;
            color: #f8f8f2;
            border-radius: 0.5rem;
            position: relative;
        }
        .code-lang {
            position: absolute;
            top: 0.5rem;
            right: 1rem;
            color: #ccc;
            font-size: 0.8rem;
        }
        .comparison-table {
            border-collapse: separate;
            border-spacing: 0;
            width: 100%;
            overflow: hidden;
            border-radius: 0.75rem;
            box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
        }
        .comparison-table th {
            background-color: #6e48aa;
            color: white;
            padding: 1rem;
            text-align: left;
        }
        .comparison-table td {
            padding: 1rem;
            border-bottom: 1px solid #e2e8f0;
        }
        .comparison-table tr:nth-child(even) {
            background-color: #f8f9fa;
        }
        .comparison-table tr:hover {
            background-color: #edf2f7;
        }
        .feature-card {
            transition: all 0.3s ease;
            border-radius: 0.75rem;
            overflow: hidden;
            box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
        }
        .feature-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
        }
        .section-divider {
            height: 1px;
            background: linear-gradient(90deg, transparent, rgba(110, 72, 170, 0.5), transparent);
            margin: 3rem 0;
        }
        .drop-cap:first-letter {
            float: left;
            font-size: 3.5rem;
            line-height: 1;
            padding: 0 0.5rem 0 0;
            margin: 0.25rem 0.5rem 0 0;
            color: #6e48aa;
            font-weight: bold;
        }
    </style>
</head>
<body class="antialiased">
    <!-- Hero Section -->
    <header class="hero-gradient text-white py-16 md:py-24">
        <div class="container mx-auto px-6 max-w-4xl">
            <div class="flex flex-col items-center text-center">
                <div class="w-20 h-20 mb-6 rounded-full bg-white bg-opacity-20 flex items-center justify-center">
                    <i class="fas fa-code text-3xl text-white"></i>
                </div>
                <h1 class="text-3xl md:text-4xl font-bold mb-4 font-serif">Java方法重载与重写</h1>
                <p class="text-xl md:text-2xl text-white text-opacity-90 mb-6 max-w-2xl">深入理解面向对象编程中的两个核心概念</p>
                <p class="text-lg text-white text-opacity-80 mb-8 drop-cap">方法重载(Overloading)和方法重写(Overriding)是Java中两个重要的概念，它们在面向对象编程中起着关键作用。理解它们的区别有助于更好地设计和实现类的行为。</p>
                <div class="flex space-x-4">
                    <a href="#overloading" class="px-6 py-2 bg-white text-purple-800 rounded-full font-medium hover:bg-opacity-90 transition">方法重载</a>
                    <a href="#overriding" class="px-6 py-2 bg-transparent border-2 border-white text-white rounded-full font-medium hover:bg-white hover:bg-opacity-10 transition">方法重写</a>
                </div>
            </div>
        </div>
    </header>

    <!-- Main Content -->
    <main class="container mx-auto px-6 py-12 max-w-4xl">
        <!-- Overloading Section -->
        <section id="overloading" class="mb-16">
            <div class="flex items-center mb-8">
                <div class="w-10 h-10 rounded-full bg-purple-100 flex items-center justify-center mr-4">
                    <i class="fas fa-layer-group text-purple-600"></i>
                </div>
                <h2 class="text-2xl md:text-3xl font-bold text-gray-800 font-serif">1. 方法重载 (Overloading)</h2>
            </div>
            <p class="text-lg text-gray-700 mb-6">方法重载是指在同一个类中，允许定义多个同名但参数列表不同的方法。参数列表的不同可以是参数的类型、数量或顺序不同。</p>
            
            <div class="grid md:grid-cols-2 gap-6 mb-8">
                <div class="feature-card bg-white p-6">
                    <h3 class="text-xl font-semibold mb-3 text-purple-700 flex items-center">
                        <i class="fas fa-check-circle mr-2"></i> 特点
                    </h3>
                    <ul class="space-y-2 text-gray-700">
                        <li class="flex items-start">
                            <i class="fas fa-circle text-xs text-purple-500 mt-2 mr-2"></i>
                            <span><strong>同一类中：</strong>重载的方法在同一类内定义，或在子类中重写父类的重载方法</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-circle text-xs text-purple-500 mt-2 mr-2"></i>
                            <span><strong>参数列表不同：</strong>方法名称相同，但参数的类型、数量或顺序必须不同</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-circle text-xs text-purple-500 mt-2 mr-2"></i>
                            <span><strong>返回类型不影响重载：</strong>即使返回类型不同，如果参数列表没有变化，也不能算作重载</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-circle text-xs text-purple-500 mt-2 mr-2"></i>
                            <span><strong>编译时多态：</strong>重载是编译时多态（静态多态），方法的选择在编译时决定</span>
                        </li>
                    </ul>
                </div>
                
                <div class="code-block p-4">
                    <div class="code-lang">Java</div>
                    <pre class="overflow-x-auto"><code class="text-sm">class Calculator {
    public int add(int a, int b) {
        return a + b;
    }

    public double add(double a, double b) {
        return a + b;
    }

    public int add(int a, int b, int c) {
        return a + b + c;
    }
}</code></pre>
                </div>
            </div>
            
            <div class="bg-blue-50 border-l-4 border-blue-500 p-4 mb-8">
                <div class="flex">
                    <div class="flex-shrink-0">
                        <i class="fas fa-info-circle text-blue-500 text-xl"></i>
                    </div>
                    <div class="ml-3">
                        <h3 class="text-sm font-medium text-blue-800">专业提示</h3>
                        <div class="mt-2 text-sm text-blue-700">
                            <p>方法重载不仅提高了代码的可读性，还能让类提供相同功能的不同实现方式，而不需要为每种情况创建不同的方法名称。</p>
                        </div>
                    </div>
                </div>
            </div>
        </section>
        
        <div class="section-divider"></div>
        
        <!-- Overriding Section -->
        <section id="overriding" class="mb-16">
            <div class="flex items-center mb-8">
                <div class="w-10 h-10 rounded-full bg-green-100 flex items-center justify-center mr-4">
                    <i class="fas fa-exchange-alt text-green-600"></i>
                </div>
                <h2 class="text-2xl md:text-3xl font-bold text-gray-800 font-serif">2. 方法重写 (Overriding)</h2>
            </div>
            <p class="text-lg text-gray-700 mb-6">方法重写是指在子类中重新定义父类中已经存在的方法，方法的名称、参数列表及返回类型必须完全相同。</p>
            
            <div class="grid md:grid-cols-2 gap-6 mb-8">
                <div class="code-block p-4">
                    <div class="code-lang">Java</div>
                    <pre class="overflow-x-auto"><code class="text-sm">class Animal {
    public void sound() {
        System.out.println("动物发出声音");
    }
}

class Dog extends Animal {
    @Override
    public void sound() {
        System.out.println("狗叫");
    }
}</code></pre>
                </div>
                
                <div class="feature-card bg-white p-6">
                    <h3 class="text-xl font-semibold mb-3 text-green-700 flex items-center">
                        <i class="fas fa-check-circle mr-2"></i> 特点
                    </h3>
                    <ul class="space-y-2 text-gray-700">
                        <li class="flex items-start">
                            <i class="fas fa-circle text-xs text-green-500 mt-2 mr-2"></i>
                            <span><strong>子类中重写父类的方法：</strong>重写发生在子类和父类之间</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-circle text-xs text-green-500 mt-2 mr-2"></i>
                            <span><strong>方法签名完全相同：</strong>名称、参数列表和返回类型都必须一致</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-circle text-xs text-green-500 mt-2 mr-2"></i>
                            <span><strong>动态多态：</strong>重写是动态多态（运行时多态），方法的选择在运行时决定</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-circle text-xs text-green-500 mt-2 mr-2"></i>
                            <span><strong>@Override 注解：</strong>使用 @Override 注解可以提高可读性，并在编译时检查重写是否符合规范</span>
                        </li>
                    </ul>
                </div>
            </div>
            
            <div class="bg-yellow-50 border-l-4 border-yellow-400 p-4 mb-8">
                <div class="flex">
                    <div class="flex-shrink-0">
                        <i class="fas fa-exclamation-triangle text-yellow-500 text-xl"></i>
                    </div>
                    <div class="ml-3">
                        <h3 class="text-sm font-medium text-yellow-800">注意事项</h3>
                        <div class="mt-2 text-sm text-yellow-700">
                            <p>子类重写的方法不能比父类被重写方法声明更多的异常，访问修饰符的限制性不能比父类方法更强（例如父类方法是public，子类不能是protected）。</p>
                        </div>
                    </div>
                </div>
            </div>
        </section>
        
        <div class="section-divider"></div>
        
        <!-- Comparison Section -->
        <section class="mb-16">
            <div class="flex items-center mb-8">
                <div class="w-10 h-10 rounded-full bg-indigo-100 flex items-center justify-center mr-4">
                    <i class="fas fa-balance-scale text-indigo-600"></i>
                </div>
                <h2 class="text-2xl md:text-3xl font-bold text-gray-800 font-serif">3. 总结与区别</h2>
            </div>
            
            <div class="mb-8">
                <table class="comparison-table">
                    <thead>
                        <tr>
                            <th class="rounded-tl-lg">特性</th>
                            <th class="rounded-tr-lg">方法重载</th>
                            <th>方法重写</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>发生位置</td>
                            <td>同一类内或子类中</td>
                            <td>子类对父类方法的重新定义</td>
                        </tr>
                        <tr>
                            <td>参数列表</td>
                            <td>必须不同（类型、数量、顺序）</td>
                            <td>必须完全相同</td>
                        </tr>
                        <tr>
                            <td>返回类型</td>
                            <td>可以不同</td>
                            <td>必须相同（或子类）</td>
                        </tr>
                        <tr>
                            <td>多态类型</td>
                            <td>静态多态（编译时）</td>
                            <td>动态多态（运行时）</td>
                        </tr>
                        <tr>
                            <td class="rounded-bl-lg">目的</td>
                            <td>提高可读性，支持不同参数类型的同一操作</td>
                            <td class="rounded-br-lg">实现子类对父类方法的具体实现，增强行为的灵活性</td>
                        </tr>
                    </tbody>
                </table>
            </div>
            
            <!-- Visualization -->
            <div class="bg-white rounded-xl p-6 shadow-md mb-8">
                <h3 class="text-xl font-semibold mb-4 text-gray-800">概念关系图解</h3>
                <div class="mermaid">
                    classDiagram
                        class Calculator {
                            +add(int a, int b) int
                            +add(double a, double b) double
                            +add(int a, int b, int c) int
                        }
                        
                        class Animal {
                            +sound() void
                        }
                        
                        class Dog {
                            +sound() void
                        }
                        
                        Animal <|-- Dog
                        note for Calculator "方法重载示例\n同一类中同名方法\n参数列表不同"
                        note for Dog "方法重写示例\n子类重写父类方法\n方法签名完全相同"
                </div>
            </div>
            
            <div class="bg-purple-50 border-l-4 border-purple-500 p-4">
                <div class="flex">
                    <div class="flex-shrink-0">
                        <i class="fas fa-lightbulb text-purple-500 text-xl"></i>
                    </div>
                    <div class="ml-3">
                        <h3 class="text-sm font-medium text-purple-800">应用场景</h3>
                        <div class="mt-2 text-sm text-purple-700">
                            <p><strong>方法重载</strong>：当你需要为相似的操作提供不同的参数组合时使用（如不同类型的加法运算）</p>
                            <p class="mt-2"><strong>方法重写</strong>：当你需要在子类中改变或扩展父类行为时使用（如不同动物的发声行为）</p>
                        </div>
                    </div>
                </div>
            </div>
        </section>
    </main>
    
    <!-- Footer -->
    <footer class="bg-gray-900 text-white py-8">
        <div class="container mx-auto px-6 text-center">
            <div class="mb-4">
                <h3 class="text-xl font-medium">技术小馆</h3>
                <p class="text-gray-400">分享编程知识与技术见解</p>
            </div>
            <div>
                <a href="http://www.yuque.com/jtostring" class="text-gray-300 hover:text-white transition duration-300 inline-flex items-center">
                    <i class="fas fa-globe mr-2"></i> http://www.yuque.com/jtostring
                </a>
            </div>
        </div>
    </footer>
    
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true
            }
        });
        
        // Smooth scrolling for anchor links
        document.querySelectorAll('a[href^="#"]').forEach(anchor => {
            anchor.addEventListener('click', function (e) {
                e.preventDefault();
                document.querySelector(this.getAttribute('href')).scrollIntoView({
                    behavior: 'smooth'
                });
            });
        });
    </script>
</body>
</html>
```